package com.green.model;

import java.util.Date;

import com.green.model.manage.Person;

/**
 * 实体基类的扩展
 * @author google  
 *
 * @since 2013-11-23
 */
public abstract class ExtraEntity<T> extends Entity<T> {

	private static final long serialVersionUID = 10L;

	private Person createBy;// 创建人
	private Date createTime;// 创建时间
	private Person lastUpdateBy;// 最后更新人
	private Date lastUpdateTime;// 最后更新时间

	
	public Person getCreateBy() {
		return createBy;
	}

	public void setCreateBy(Person createBy) {
		this.createBy = createBy;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Person getLastUpdateBy() {
		return lastUpdateBy;
	}

	public void setLastUpdateBy(Person lastUpdateBy) {
		this.lastUpdateBy = lastUpdateBy;
	}

	public Date getLastUpdateTime() {
		return lastUpdateTime;
	}

	public void setLastUpdateTime(Date lastUpdateTime) {
		this.lastUpdateTime = lastUpdateTime;
	}

    /**
     * 将实体相等与否 寄托于 ID是否相等
     * @author lineshow   Email:lineshow7@gmail.com
     * @since 2012-4-5
     */
	@SuppressWarnings("unchecked")
	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if(obj instanceof ExtraEntity){
			T objId = ((ExtraEntity<T>)obj).getId();
			if(objId == null && this.getId() == null){
				return true;
			}
			if(objId == null || !objId.equals(this.getId())){
				return false;
			}else{
				return true;
			}
		}
		return false;
	}
}
